<template>
  <div>
     <detail-header :sightName="sightName"></detail-header>
     <detail-banner :sightName="sightName" :bannerImg="bannerImg" :gallaryImgs="gallaryImgs"></detail-banner>
     <detail-baseinfo></detail-baseinfo>
     <detail-list :list="list" @change="handlechange"></detail-list>
  </div>
</template>

<script>
import DetailBanner  from './components/Banner'
import DetailHeader  from './components/Header'
import DetailList  from './components/List'
import DetailBaseinfo  from './components/Baseinfo'
import axios from 'axios'
export default {
  name: 'Detail',
  components:{
      DetailBanner,
      DetailHeader,
      DetailList,
      DetailBaseinfo
  },
  data () {
    return {
      sightName:'',
      bannerImg:'',
      gallaryImgs: [],
      list: []
    }
  },
  methods: {
    getDetailInfo () {
      axios.get('/api/detail.json',{
        params: {
          id: this.$route.params.id
        }
      }).then(this.handleGetDataSucc)
    },
    handleGetDataSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.sightName = data.sightName
        this.bannerImg = data.bannerImg
        this.gallaryImgs = data.gallaryImgs
        data.categoryList.forEach(element => {
          element.children.forEach(item=>{
            item.isopen = false
          })
        });
        this.list = data.categoryList
      }
    },
    handlechange(option){
      this.list[option.index].children[option.i].isopen = !this.list[option.index].children[option.i].isopen
    }
  },
  mounted () {
    this.getDetailInfo()
  },
  // activated () {
  //   this.getDetailInfo()
  // }
}
</script>

<style lang="scss">
</style>
